package com.atldy.commerce.controller;

import com.atldy.commerce.account.BalanceInfo;
import com.atldy.commerce.service.EcommerceBalanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-08-14 21:14
 * @Description：
 */
@RestController
@Api("用户余额信息")
@RequestMapping("/balance")
public class BalanceController {

    @Autowired
    private EcommerceBalanceService balanceService;

    /**
     * 根据当前用户id获取余额信息
     */
    @ApiOperation(value = "当前用户", notes = "当前用户余额信息")
    @GetMapping("/getCurrentBalanceByUserId")
    public BalanceInfo getCurrentBalanceByUserId() {
        return balanceService.getCurrentBalanceByUserId();
    }

    /**
     * 扣减余额
     */
    @ApiOperation(value = "扣减余额", notes = "扣减余额-当前用户余额")
    @PostMapping("/deductionsBalanceInfo")
    public BalanceInfo deductionsBalanceInfo(@RequestBody BalanceInfo balanceInfo) {
        return balanceService.deductionsBalanceInfo(balanceInfo);
    }

}